<template>
  <div class="home_container">
    <div class="screen" ref="screen">
      <div class="home_top"><Top /></div>
      <div class="home_bottom">
        <div class="home_left">
          <div class="monitor_title"></div>
          <Monitor class="monitor" />
          <Rank class="rank" />
          <Construction class="construction" />
        </div>
        <div class="home_center">
          <Map class="map" />
          <Strength class="strength" />
        </div>
        <div class="home_right">
          <div class="monitor_title"></div>
          <Emission class="emission" />
          <Label class="label" />
          <Trend class="trend" />
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { onMounted, ref } from 'vue'
import Top from './components/Top/index.vue'
import Monitor from './components/Monitor/index.vue'
import Rank from './components/Rank/index.vue'
import Construction from './components/Construction/index.vue'
import Map from './components/Map/index.vue'
import Strength from './components/Strength/index.vue'
import Emission from './components/Emission/index.vue'
import Label from './components/Label/index.vue'
import Trend from './components/Trend/index.vue'

// 判断视口大小/监听
let screen = ref()
onMounted(() => {
  screen.value.style.transform = `scale(${getScale()}) translate(-50%,-50%)`
})
window.onresize = () => {
  screen.value.style.transform = `scale(${getScale()}) translate(-50%,-50%)`
}

// 大屏缩放比例
function getScale(w = 1920, h = 1080) {
  const ww = window.innerWidth / w
  const wh = window.innerHeight / h
  return ww < wh ? ww : wh
}
</script>
<style lang="scss" scoped>
.home_container {
  width: 100vw;
  height: 100vh;
  background: radial-gradient(#0a3a87, #02132e);
  .screen {
    position: fixed;
    left: 50%;
    top: 50%;
    width: 1920px;
    height: 1080px;
    transform-origin: left top;
    .home_top {
      width: 100%;
      height: 134px;
      // background: red;
    }
    .home_bottom {
      width: 100%;
      display: flex;
      height: 946px;
      .home_left {
        width: 547px;
        display: flex;
        flex-direction: column;
        align-items: center;
        .monitor_title {
          width: 275px;
          height: 26px;
          background: url(../../assets/svg/tanjiance.svg) no-repeat;
        }
        .monitor {
          height: 282px;
        }
        .rank {
          height: 281px;
        }
        .construction {
          height: 293px;
        }
      }
      .home_center {
        width: 784px;
        display: flex;
        flex-direction: column;
        align-items: center;
        margin-top: 20px;
        .map {
          width: 100%;
          height: 544px;
          background-color: #fff;
        }
        .strength {
          width: 100%;
          height: 337px;
          // background-color: saddlebrown;
        }
      }
      .home_right {
        width: 589px;
        display: flex;
        flex-direction: column;
        align-items: center;
        .monitor_title {
          width: 275px;
          height: 26px;
          background: url(../../assets/svg/tanpingjia.svg) no-repeat;
        }
        .emission {
          width: 100%;
          height: 292px;
        }
        .label {
          width: 100%;
          height: 285px;
          // background-color: saddlebrown;
        }
        .trend {
          width: 100%;
          height: 329px;
        }
      }
    }
  }
}
</style>
